<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>统计</title>
    <link href="/res/third/bootstrap3/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
</head>
<body  >
<div class="panel panel-default panel-content" style="overflow-y:auto;">
    <div id="main" style="width: 100%;height:500px;"></div>
    <div id="view">

    </div>
</div>
</body>
<script src="/res/common/js/jquery.1.9.1.min.js" type="text/javascript"></script>
<script id="usertable"  type="text/html">
    <table class="table table-bordered table-hover table-striped">
        <tr>
            <th>新增</th>
            {{each xAxis}}
            <th>{{$value}}</th>
            {{/each}}
        </tr>

        <tr>
            <th>注册用户</th>
        {{each totals}}
            <td>{{$value}}</td>
        {{/each}}
        </tr>
        {{each series}}
            {{if $index ==0 }}
                <th>认证过的</th>
            {{/if}}
            {{if $index ==1 }}
                <th>供应商</th>
            {{/if}}
            {{if $index ==2 }}
                <th>采购商</th>
            {{/if}}
            {{if $index ==3 }}
                <th>双身份</th>
            {{/if}}

            {{each series[$index].data}}
                <td>{{$value}}</td>
            {{/each}}
        </tr>
        {{/each}}
    </table>
</script>

<script src="/res/third/echarts/echarts.min.js" type="text/javascript"></script>
<script src="/res/third/laytpl/template.js" type="text/javascript"></script>
<script src="/res/common/js/china.js" type="text/javascript"></script>
<script>
    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('main'));

    // 指定图表的配置项和数据
    var option = {
        title: {
            text: '新增认证用户'
        },
        tooltip: {},
        legend: {
            data:[]
        },
        xAxis: {
            data: []
        },
        yAxis: {},
        series: []
    };
    // 使用刚指定的配置项和数据显示图表。
       myChart.setOption(option);
//    myChart.clear();
    myChart.showLoading({text: '正在努力的读取数据中...'});
    $.getJSON('/echarts/user/added.do', function (data) {
        if (data.success) {
            myChart.setOption(data.obj, true);
            myChart.hideLoading();
            console.log(data.attributes.totals);
            console.log(data.obj);
            var tpldata = {
                xAxis:data.obj.xAxis[0].data,
                series:data.obj.series,
                totals:data.attributes.totals.data
            };
            var html = template("usertable",tpldata);
            document.getElementById('view').innerHTML = html;
        } else {
            alert('提示', data.msg);
        }
    });


</script>

</html>